<section id="behavior">
    {% if results.behavior and results.behavior.anomaly %}
        <div class="section-title">
            <h4>Anomalies</h4>
        </div>
        <div class="card card-body">
            <ul>
                {% for anomaly in results.behavior.anomaly %}
                <li><span class="mono">
                    <b>{{anomaly.category}} {{anomaly.funcname}}</b>
                    {{anomaly.message}}
                    (pid={{anomaly.pid}}, process={{anomaly.name}})
                </span></li>
                {% endfor %}
            </ul>
        </div>
    {% endif %}
    {% if results.behavior and results.behavior.summary %}
        <div class="section-title">
            <h4>Behavior Summary</h4>
        </div>
        <div class="card card-body">
            <b>Mutexes</b>
            {% if results.behavior.summary.mutexes %}
                <ul>
                    {% for mutex in results.behavior.summary.mutexes %}
                    <li><span class="mono">{{mutex}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Executed Commands</b>
            {% if results.behavior.summary.executed_commands %}
                <ul>
                    {% for cmd in results.behavior.summary.executed_commands %}
                    <li><span class="mono">{{cmd}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Created Services</b>
            {% if results.behavior.summary["created_services"] %}
                <ul>
                    {% for service in results.behavior.summary["created_services"] %}
                    <li><span class="mono">{{service}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Started Services</b>
            {% if results.behavior.summary["started_services"] %}
                <ul>
                    {% for service in results.behavior.summary["started_services"] %}
                    <li><span class="mono">{{service}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
    {% endif %}

    <div class="section-title">
        <h4>Processes</h4>
    </div>
    {% if summary_report %}
        {% if results.behavior and results.behavior.processes %}
            {% for process in results.behavior.processes %}
                <div>
                    <h4>{{process.process_name}} <small>PID: {{process.process_id}}, Parent PID: {{process.parent_id}}</small></h4>
                </div>
            {% endfor %}
        {% else %}
            Nothing to display.
        {% endif %}
    {% else %}
    <p>
        <span class="badge registry" style="color: black;">registry</span>
        <span class="badge filesystem" style="color: black;">filesystem</span>
        <span class="badge process" style="color: black;">process</span>
        <span class="badge threading" style="color: black;">threading</span>
        <span class="badge services" style="color: black;">services</span>
        <span class="badge device" style="color: black;">device</span>
        <span class="badge network" style="color: black;">network</span>
        <span class="badge synchronization" style="color: black;">synchronization</span>
        <span class="badge crypto" style="color: black;">crypto</span>
        <span class="badge browser" style="color: black;">browser</span>
    </p>
    {% if results.behavior and results.behavior.processes %}
        {% for process in results.behavior.processes %}
        <div>
            <h4><a href="javascript:showHide('process_{{process.process_id}}');">{{process.process_name}}</a>
                <small>PID: {{process.process_id}}, Parent PID: {{process.parent_id}}, Full Path: <b>{{process.module_path}}</b>
                    {% if process.environ.CommandLine %}
                    , Command Line: <b>{{ process.environ.CommandLine }}</b>
                    {% endif %}
                </small>
            </h4>
            {% if results.local_conf.apicalls %}
            <div id="process_{{process.process_id}}" style="display: none;">
                <table class="table table-bordered table-condensed" style="width: 100%; word-wrap:break-word;table-layout: fixed;">
                    <tr>
                        <th width="10%">Timestamp</th>
                        <th width="5%">Thread</th>
                        <th width="15%">Function</th>
                        <th width="50%">Arguments</th>
                        <th width="5%">Status</th>
                        <th width="10%">Return</th>
                        <th width="5%">Repeated</th>
                    </tr>
                    {% for call in process.calls %}
                    <tr class="{{call.category}}">
                        <td>{{call.timestamp[11:]}}</td>
                        <td>{{call.thread_id}}</td>
                        <td><span class="mono">{{call.api}}</span></td>
                        <td style="word-wrap: break-word;">
                        {% for argument in call.arguments %}
                            {% if argument.pretty_value %}
                                {{argument.name}} => <span class="mono" title="{{argument.value}}">{{argument.pretty_value}}</span><br />
                            {% else %}
                                {{argument.name}} => <span class="mono">{{argument.value}}</span><br />
                            {% endif %}
                        {% endfor %}
                        </td>
                        <td>{% if call.status %}SUCCESS{% else %}FAILURE{% endif %}</td>
                        {% if call.pretty_return %}
                            <td style="word-wrap: break-word;"><span class="mono" title="{{call.return}}">{{call.pretty_return}}</span></td>
                        {% else %}
                            <td><span class="mono">{{call.return}}</span></td>
                        {% endif %}
                        <td>
                        {% if call.repeated and call.repeated > 0 %}
                            {{call.repeated}}
                            {% if call.repeated == 1 %}
                             time
                            {% elif call.repeated > 1 %}
                             times
                            {% endif %}
                        {% endif %}
                        </td>
                    </tr>
                    {% endfor %}
                </table>
            </div>
            {% endif %}
        </div>
        {% endfor %}
    {% else %}
        Nothing to display.
    {% endif %}
    {% endif %}
        <div class="card card-body">
            <b>Accessed Files</b>
            {% if results.behavior.summary.files %}
                <ul>
                    {% for file in results.behavior.summary.files %}
                    <li><span class="mono">{{file}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Read Files</b>
            {% if results.behavior.summary.read_files %}
                <ul>
                    {% for file in results.behavior.summary.read_files %}
                    <li><span class="mono">{{file}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Modified Files</b>
            {% if results.behavior.summary.write_files %}
                <ul>
                    {% for file in results.behavior.summary.write_files %}
                    <li><span class="mono">{{file}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Deleted Files</b>
            {% if results.behavior.summary.delete_files %}
                <ul>
                    {% for file in results.behavior.summary.delete_files %}
                    <li><span class="mono">{{file}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Registry Keys</b>
            {% if results.behavior.summary["keys"] %}
                <ul>
                    {% for key in results.behavior.summary["keys"] %}
                    <li><span class="mono">{{key}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Read Registry Keys</b>
            {% if results.behavior.summary["read_keys"] %}
                <ul>
                    {% for key in results.behavior.summary["read_keys"] %}
                    <li><span class="mono">{{key}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Modified Registry Keys</b>
            {% if results.behavior.summary["write_keys"] %}
                <ul>
                    {% for key in results.behavior.summary["write_keys"] %}
                    <li><span class="mono">{{key}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Deleted Registry Keys</b>
            {% if results.behavior.summary["delete_keys"] %}
                <ul>
                    {% for key in results.behavior.summary["delete_keys"] %}
                    <li><span class="mono">{{key}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
        <div class="card card-body">
            <b>Resolved APIs</b>
            {% if results.behavior.summary.resolved_apis %}
                <ul>
                    {% for api in results.behavior.summary.resolved_apis %}
                    <li><span class="mono">{{api}}</span></li>
                    {% endfor %}
                </ul>
            {% else %}
                Nothing to display.
            {% endif %}
        </div>
</section>
